import type { BasicTableColumn } from '@/components/table';
import TableFieldType from '@/components/table/src/types/field-type';
import type { FormSchema } from '@/components/form';
import FormFieldType from '@/components/form/src/types/field-type';

export const columns: BasicTableColumn[] = [
  {
    title: 'roleId',
    key: 'roleId',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '角色名称',
    key: 'roleName',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '角色权限',
    key: 'roleKey',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '数据范围',
    key: 'dataScope',
    display: false,
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '备注',
    key: 'remark',
    fieldType: TableFieldType.TEXT,
  },
  {
    title: '状态',
    key: 'status',
    fieldType: TableFieldType.TAG,
    width: 100,
    align: 'center',
    tagOptions: {
      options: [
        {
          label: '正常',
          value: '0',
          type: 'success',
        },
        {
          label: '停用',
          value: '1',
          type: 'error',
        },
      ],
    },
  },
  {
    title: '创建时间',
    key: 'createTime',
    fieldType: TableFieldType.TEXT,
  },
];

export const formSchemas: FormSchema[] = [
  {
    field: 'roleName',
    component: FormFieldType.INPUT,
    label: '角色名称',
    rules: [{ required: true, message: '请输入角色名称', trigger: ['blur'] }],
  },
  {
    field: 'roleKey',
    component: FormFieldType.INPUT,
    label: '角色权限',
    rules: [{ required: true, message: '请输入角色权限', trigger: ['blur'] }],
  },
  {
    field: 'roleSort',
    component: FormFieldType.INPUT_NUMBER,
    label: '排序',
    rules: [{ required: true, message: '请输入排序', trigger: ['blur'] }],
  },
  {
    field: 'dataScope',
    component: FormFieldType.SELECT,
    label: '数据范围',
    componentProps: {
      valueField: 'value',
      options: [
        {
          label: '全部数据权限',
          value: '1',
        },
        {
          label: '自定数据权限',
          value: '2',
        },
        {
          label: '本部门数据权限',
          value: '3',
        },
        {
          label: '本部门及以下数据权限',
          value: '4',
        },
      ],
    },
  },
  {
    field: 'menuCheckStrictly',
    component: FormFieldType.SWITCH,
    label: '菜单选择项',
    labelMessage: '菜单树选择项是否关联显示',
    defaultValue: true,
    display: false,
  },
  {
    field: 'menuIds',
    component: FormFieldType.SELECT,
    label: '菜单权限',
    display: false,
    defaultValue: [],
  },
  {
    field: 'deptCheckStrictly',
    component: FormFieldType.SWITCH,
    label: '部门选择项',
    labelMessage: '部门树选择项是否关联显示',
    defaultValue: true,
    display: false,
  },
  {
    field: 'deptIds',
    component: FormFieldType.SELECT,
    label: '数据权限',
    display: false,
    defaultValue: [],
  },
  {
    field: 'status',
    component: FormFieldType.RADIO_GROUP,
    label: '状态',
    componentProps: {
      options: [
        {
          label: '正常',
          value: '0',
        },
        {
          label: '停用',
          value: '1',
        },
      ],
    },
    defaultValue: '0',
  },
  {
    field: 'remark',
    component: FormFieldType.INPUT,
    label: '备注',
    componentProps: {
      type: 'textarea',
    },
    giProps: {
      span: 2,
    },
  },
];

export const searchSchemas: FormSchema[] = [
  {
    field: 'roleName',
    component: FormFieldType.INPUT,
    label: '角色名称',
  },
  {
    field: 'roleKey',
    component: FormFieldType.INPUT,
    label: '角色权限',
  },
  {
    field: 'dataScope',
    component: FormFieldType.SELECT,
    label: '数据范围',
    componentProps: {
      options: [
        {
          label: '全部数据权限',
          value: '1',
        },
        {
          label: '自定数据权限',
          value: '2',
        },
        {
          label: '本部门数据权限',
          value: '3',
        },
        {
          label: '本部门及以下数据权限',
          value: '4',
        },
      ],
    },
  },
  {
    field: 'status',
    component: FormFieldType.SELECT,
    label: '状态',
    componentProps: {
      valueField: 'value',
      options: [
        {
          label: '正常',
          value: '0',
        },
        {
          label: '停用',
          value: '1',
        },
      ],
    },
    defaultValue: null,
  },
];
